package com.ruoyi.web.controller.system;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.DefDrill;
import com.ruoyi.system.domain.vo.*;
import com.ruoyi.system.service.IDefDrillService;
import com.ruoyi.system.service.IDefGainService;
import com.ruoyi.system.service.IDefTeamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Description: TODO
 * @author: xuexing
 * @Date: 2024/10/17 15:08
 */
@RestController
@RequestMapping("/screen")
public class ScreenController extends BaseController {

    @Autowired
    IDefTeamService defTeamService;
    @Autowired
    IDefGainService defGainService;
    @Autowired
    IDefDrillService defDrillService;

    /**
     * @param drillId
     * @return com.ruoyi.system.domain.vo.PartakeTeamVO
     * @Description: 参与团队
     */
    @GetMapping("/viewPartake")
    public AjaxResult viewPartake(Integer drillId) {
        return AjaxResult.success(defTeamService.viewPartakeCount(drillId));
    }

    /**
     * @param drillId
     * @return com.ruoyi.system.domain.DefDrill
     * @Description: 根据drillId获取演练信息
     */
    @GetMapping("/getDrillById")
    public AjaxResult getDrillById(Integer drillId) {
        return AjaxResult.success(defDrillService.selectDefDrillByDrillId(drillId));
    }

    /**
     * @param drillId
     * @return com.ruoyi.system.domain.vo.PartakeTeamVO
     * @Description: 总得分情况
     */
    @GetMapping("/getAllScore")
    public AjaxResult aggTime(Integer drillId) {
        return AjaxResult.success(defTeamService.getAllScore(drillId));
    }

    /**
     * @param drillId
     * @return java.util.List<com.ruoyi.system.domain.vo.PartakeTeamVO>
     * @Description: 攻防得分分布
     */
    @GetMapping("/timeScore")
    public AjaxResult timeScore(Integer drillId) {
        return AjaxResult.success(defTeamService.getTimeScore(drillId));
    }

    /**
     * @param drillId
     * @param type
     * @return java.util.List<com.ruoyi.system.domain.vo.DefGainAggVO>
     * @Description: 攻防得分排名
     */
    @GetMapping("/getGain")
    public AjaxResult getGain(Integer drillId, Integer type) {
        if (0 == type) {
            return AjaxResult.success(defGainService.sortDefend(drillId));
        } else {
            return AjaxResult.success(defGainService.sortAttack(drillId));
        }
    }

    /**
     * @param drillId
     * @return java.util.List<com.ruoyi.system.domain.vo.DefGainResultVO>
     * @Description: 攻防成果实时展示
     */
    @GetMapping("/showResult")
    public AjaxResult showResult(Integer drillId) {
        return AjaxResult.success(defGainService.resultShow(drillId));
    }

    /**
     * @param drillId
     * @return com.ruoyi.system.domain.vo.LevelVO
     * @Description: 成果等级
     */
    @GetMapping("/resultLevel")
    public AjaxResult resultLevel(Integer drillId) {
        return AjaxResult.success(defGainService.resultLevel(drillId));
    }

    /**
     * @param drillId
     * @return java.util.List<com.ruoyi.system.domain.vo.CountVO>
     * @Description: 被攻陷单位排名
     */
    @GetMapping("/unitSort")
    public AjaxResult unitSort(Integer drillId) {
        return AjaxResult.success(defGainService.unitSort(drillId));
    }
}
